#include <iostream>
#include <unordered_map>

using namespace std;

const int N = 1e6 + 10;
int a[N];
int t, n;


int main()
{
	cin >> t;
	while(t--)
	{
		cin >> n;
		for(int i = 1; i <= n; i++) cin >> a[i];
		int l = 1, r = 1, ans = 0;
		unordered_map<int, int> mp;
		while(r <= n)
		{
			mp[a[r]]++;
			while(mp[a[r]]> 1)
			{
				mp[a[l]]--;
				l++;
			}
			ans = max(ans, r - l + 1);
			r++;	
		} 
		cout << ans << endl;
	}
	
	return 0;
}
